<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>追加红包</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.js"></script>
		<style type="text/css">
			#sfz_pic{position: relative;}/*opacity: 0;*/
			 .upload,.upload1{position: absolute;top: 0;left: 0;width: 100%;height: 100%;opacity: 0;}
		</style>
	</head>

	<body>
		<form class="layui-form update_form">
			<div class="layui-form-item">
				<label class="layui-form-label">追加人数</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="id" style="display: none;" value="{$data.id}">
					<input type="text" name="user_num" id="user_num" required lay-verify="required" placeholder="追加人数" autocomplete="off" class="layui-input" onkeyup="value=value.replace(/[^\d\.]/g,'')" onblur="value=value.replace(/[^\d\.]/g,'')">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">增加鼓励金</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="gold_sum" id="gold_sum" onkeyup="keyup(this)" required lay-verify="required" placeholder="增加鼓励金" autocomplete="off" class="layui-input" onkeyup="value=value.replace(/[^\d\.]/g,'')" onblur="value=value.replace(/[^\d\.]/g,'')">
				</div>
			</div>
			<div class="layui-form-item" style="padding-top: 12px;">
				<label class="layui-form-label">备注</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="memo" value="{$data.memo}" required placeholder="恭喜发财 大吉大利" autocomplete="off" class="layui-input" >
				</div>
			</div>
			<div class="layui-form-item update_btnbox">
				<div class="layui-input-block">
					<button class="layui-btn"  lay-submit lay-filter="submit_from" type="button" >立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</body>
</html>
<script>
	layui.use('form', function() {
		var form = layui.form;
		//监听表单提交
		form.on('submit(submit_from)', function(data){
			tijiao();
  			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		});
	});
	
	function tijiao() {
		var hbmoney = $("#gold_sum").val();
		var hbnums = $("#user_num").val();
		if(hbnums>500){
			layer.msg('增加人数不能超过500');
			return;
		}
	    if(hbmoney>1000){
			layer.msg('增加鼓励金不能超过1000');
			return;
		}
		$.ajax({
			type: "post",
			url: "{:url('activet/gold_zj')}",
			data: $('.layui-form').serialize(), //表单数据
			success: function(data) {
				if(data.code == 200) {
					layer.msg(data.msg, {
						icon: 1,
						time: 1500 //2秒关闭（如果不配置，默认是3秒）
					}, function() {
						window.parent.location.reload();
						var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
						parent.layer.close(index);
					});
				} else {
					layer.msg(data.msg); //保存成功提示
					}
				},
				error: function(data) {
					var a = data;
				}
			});
	
	}

	layui.use('laydate', function(){
		var laydate = layui.laydate;
		
		//日期控件		  
		laydate.render({
		    elem: '#end_time'
		    ,type: 'datetime'
		    ,format: 'yyyy-MM-dd HH:mm:ss'
		});
		
	})
	
	function keyup(obj) {
	obj.value = obj.value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
	obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字而不是.
	obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的.
	obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
	}
</script>